﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RonaldCamcam.XBeeFramework.Api
{
    public class CommandFactory
    {
        //by default read only queue is applied
        public static ApiCommand CreateCommand(XBee xbee)
        {
            return CreateCommand(xbee, ApiId.AtCommandApiQueueOnly);
        }

        public static ApiCommand CreateCommand(XBee xbee, ApiId apiId)
        {
            switch (apiId)
            {
                case ApiId.AtCommandApiQueueOnly:
                case ApiId.AtCommandApiWithApplyChanges:
                    return new AtCommand(apiId, xbee);
            }

            throw new ApplicationException("Please specify API Identifier");
        }        

        public static ApiRemoteCommand CreateRemoteCommand(XBee xbee, ApiId apiId, byte[] remoteAddress)
        {
            switch (apiId)
            {                
                case ApiId.RemoteCommandRequest:
                    return new AtRemoteCommand(apiId, xbee, remoteAddress);
            }

            throw new ApplicationException("Please specify API Identifier");
        }        

        public static ModemCommand CreateModemCommand(ApiId apiId)
        {
            return new ModemCommand(apiId);
        }
    }
}
